package com.cy.game

import android.content.Context
import com.business.Analyse
import com.business.AnalyseKey
import com.helloandroid.AppUtil
import com.helloandroid.R
import com.helloandroid.ads.VideoAdUtil
import com.helloandroid.base.BaseDialog

class AddPowerDialog(ctx:Context) : BaseDialog(ctx) {

    private val cyAct = ctx as CyHomeActivity

    override fun getContentViewResId(): Int  = R.layout.dialog_cy_addpower;

    override fun initView() {
        // 返回
        findBtn(R.id.addPowerBackButton).setOnClickListener { cancel() }

        // 免费领取
        findBtn(R.id.addPowerButton).setOnClickListener {
            VideoAdUtil.playVideoAd(cyAct){success->
                if (success){
                    Analyse.report(AnalyseKey.Cy_PowerAdd_Video)

                    // 增加体力
                    AppUtil.appViewModel().cyRepower(AppUtil.sysTime, 5, true)
                    cyAct.mInfo?.increasePower(5)
                    cancel()
                }else{
                    AppUtil.toast("视频还没准备好!")
                }
            }
        }
    }

    override fun initData() {

    }
}